let http = require('http')
let url = require('url')
let fs = require('fs')

let server = http.createServer()

server.on('request',(req,res)=>{
    res.writeHead(200,
        {
            "content-type":"application/json;charset=utf-8",
            "access-control-allow-origin":true
        }
    )
    // let urlObj= url.parse(req.url)
    // if(urlObj === 'api/aa'){
    //     httpget(res=>res.on(spider()))
    // }else{
    //     res.send()
    // }
    fs.readFile('./1.json',(err,data)=>{
        res.write(data)
        res.end(data)
        console.log(data.toString())
    })



    // res.write(JSON.stringify('./1.json'))
})

function httpget(){
    let data = ''
    https.get('',(res)=>{
        res.on('data',(chunk)=>{
            data+chunk
        })
        res.on('',()=>[
            
        ])
    })
}
server.listen(3001,()=>{
    console.log("listening")
})